<?php
$this->breadcrumbs = array(
    '阈值管理'
);
?>
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'search-form',
    'type' => 'search',
    'method' => 'GET',
    'htmlOptions' => array('class' => 'navbar-search pull-left', 'style' => 'margin:0;width:100%;'),
));
?>
<div class="submenu">
    <div class="row">
        <div class="col-xs-2">
            <?php
            echo $form->dropDownList($model, 'type', MsggItem::getOptions('type', array('' => '===消息类型===')), array('class' => 'form-control'));
            ?>
        </div>
        <div class="col-xs-2">
            <?php
            echo $form->dropDownList($model, 'pid', MsggItem::getOptions('pid', array('' => '===关联人员===')), array('class' => 'form-control', 'data-select' => 'picker', 'data-live-search' => 'true'));
            ?>
        </div>
        <div class="col-xs-2">
            <?php
            echo $form->dropDownList($model, 'isoverclock', [''=>'是否超频','true'=>'超频','false'=>'未超频'], array('class' => 'form-control', 'data-select' => 'picker', 'data-live-search' => 'true'));
            ?>
        </div>
        <div class="col-xs-1">
            <button class="btn btn-primary" style="width:100%;" type="submit" name="yt0"><i class="fa fa-search"></i>
            </button>
        </div>
    </div>
</div>
<?php
$this->endWidget();
?>
<div>
    <?php
    $columns = array(
        array('name' => 'cnname', 'value' => array($this, 'colRevise'), 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width:10%')),
        array('name' => 'type', 'value' => array($this, 'colRevise'), 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width:10%')),
        array('name' => 'info', 'value' => array($this, 'colRevise'), 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width:60%')),
        array('class' => 'CLinkColumn',
            'label' => '<i class="fa fa-eraser"></i>',
            'urlExpression' => 'Yii::app()->getController()->createUrl("clean",array("pre"=>$data["pre"],"type"=>$data["type"]))',
            'linkHtmlOptions' => array('class' => 'clean', 'data-original-title' => '清除', 'rel' => "tooltip"),
            'headerHtmlOptions' => array('style' => 'width:3%'),
        ),
    );
    $this->widget('bootstrap.widgets.TbGridView', array(
        'id' => 'valve-grid',
        'ajaxVar' => null,
        'type' => array(),
        'enableSorting' => false,
        'dataProvider' => $model->getDataProvider(),
        'columns' => $columns,
    ));
    ?>
</div>


<script type="text/javascript">
    $(function ($) {
        $(document).on('click', 'a.clean', function () {
            if (!confirm('确定清除重新统计?')) return false;
            var th = this;
            var afterClean = function () {
            };
            $.fn.yiiGridView.update('valve-grid', {
                type: 'POST',
                url: $(this).attr('href'),
                ajaxUpdate: false,
                success: function (data) {
                    if (data == 'Success') {
                        alert(data);
                        $.fn.yiiGridView.update('valve-grid');
                    } else {
                        alert(data);
                    }
                    afterClean(th, true, data);
                },
                error: function (XHR) {
                    return afterClean(th, false, XHR);
                }
            });
            return false;
        });
    });
</script>
